import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from "axios"
// 引入阿里iconfont
import '@/assets/icon/iconfont.css' 
// 树形表格组件
import TreeTable from 'vue-table-with-tree-grid'  
Vue.component("tree-table", TreeTable)

// 添加请求拦截器
axios.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么
  config.headers.Authorization = localStorage.getItem('token')
  return config;  
}, function (error) {
  // 对请求错误做些什么
  return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
  // 对响应数据做点什么
  return response;
}, function (error) {
  // 对响应错误做点什么
  return Promise.reject(error);
}); 

Vue.use(ElementUI);

Vue.config.productionTip = false
Vue.prototype.$axios = axios

// // 使用moment
// import moment  from 'moment/moment';
// Vue.filter("timeForment",function(val){
//   return  moment(val*1000).format("Y-M-D hh:mm:ss")
// })

// 自定义全局过滤器：改变时间格式
Vue.filter("timeForment",function(val){
   let nowtime=new Date(val)
   let Y=nowtime.getFullYear();
   let M=(nowtime.getMonth()+1+"").padStart(2,"0");
   let D=(nowtime.getDate()+"").padStart(2,"0");
   let hh=(nowtime.getHours()+"").padStart(2,"0");
   let mm=(nowtime.getMinutes()+"").padStart(2,"0");
   let ss=(nowtime.getSeconds()+"").padStart(2,"0");
   return `${Y}-${M}-${D} ${hh}:${mm}:${ss}`
  })

// 引入富文本编辑器
import VueQuillEditor from 'vue-quill-editor' 
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'  
Vue.use(VueQuillEditor)
 

import _ from 'lodash';
Vue.use(_)



new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
